package com.robot.init;

import com.robot.dao.TestPlanMapper;
import com.robot.model.TestPlanDo;
import com.robot.service.TestPlanService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;

import javax.annotation.PostConstruct;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: li
 * Date: 2020/3/29
 * Time: 16:35
 * PROJECT：robot
 * PACKAGE: com.robot
 *
 * @author:55324936@qq.com To change this template use File | Settings | File Templates.
 */
@Component
public class InitScheduleTask {
    @Autowired
    TestPlanMapper testPlanMapper;
    @Autowired
    TestPlanService testPlanService;
    @PostConstruct
    public void initTask(){
      List<TestPlanDo> testPlanDos= testPlanMapper.getTestPlan(null);
      if(CollectionUtils.isEmpty(testPlanDos)){
          return;
      }
      testPlanDos.forEach(testPlanDo -> {
          testPlanService.addTask(testPlanDo);
      });
    }
}
